using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using bitzhuwei.Compiler;

namespace bitzhuwei.AnsiCFormat {
    /// <summary>
    /// Correspond to the Vn node type_name in the grammar(AnsiC).
    /// </summary>
    internal partial class Vntype_name : IFullFormatter {
        // [153]=type_name : specifier_qualifier_list ;
        // [154]=type_name : specifier_qualifier_list abstract_declarator ;

        private readonly TokenRange _scope;
        private readonly Vnspecifier_qualifier_list r1;
        private readonly Vnabstract_declarator? r0;

        public TokenRange Scope => _scope;

        public void Format(TextWriter writer, FormatContext context) {
            throw new NotImplementedException();
        }

        public void FullFormat(BlankConfig preConfig, TextWriter writer, FormatContext context) {
            context.PrintBlanksAnd(r1, preConfig, writer);
            if (r0 != null) {
                var config = new BlankConfig();
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
        }

        public IEnumerable<string> YieldTokens(TextWriter writer, FormatContext context) {
            throw new NotImplementedException();
        }

        internal Vntype_name(Vnspecifier_qualifier_list r1, Vnabstract_declarator? r0) {
            this.r1 = r1;
            this.r0 = r0;
            if (r0 != null) { this._scope = new TokenRange(r1, r0); }
            else { this._scope = new TokenRange(r1); }
        }

    }
}
